home *** CD-ROM | disk | FTP | other *** search
/ Amiga Collections: Taifun / Taifun 045 (1988-02-15)(Ossowski, Stefan)(DE)(PD).zip / Taifun 045 (1988-02-15)(Ossowski, Stefan)(DE)(PD).adf / Iff2Pcs / Source / pzdiff.c < prev    next >
C/C++ Source or Header  |  1988-01-20  |  1KB  |  59 lines

  1. #include "pz.h"
  2.  
  3. /* Gets difficulty from the user. */
  4.  
  5. #define GADWIDTH  40
  6. #define GADHEIGHT 10
  7. #define GADX      100
  8. #define GADY      300
  9. #define NUMGADS   4
  10.  
  11. struct Gadget pzgad[NUMGADS];
  12.  
  13.  
  14. unsigned short gadborderxy[] = {
  15.   -1,-1, GADWIDTH,-1, GADWIDTH, GADHEIGHT, -1, GADHEIGHT, -1,-1
  16. };
  17.  
  18. static struct Border gadborder = {0, 0, 1, 0, JAM1, 5, gadborderxy, NULL};
  19.   
  20. static struct Gadget samplegad = {
  21.   NULL, 0, GADY, GADWIDTH, GADHEIGHT,
  22.   GADGHCOMP, RELVERIFY, BOOLGADGET, &gadborder, NULL, NULL, 0L, NULL, 0, NULL};
  23.  
  24. int GetDifficulty (win)
  25. struct Window *win;
  26. {
  27.   int cnt;
  28.   struct IntuiMessage *msg;
  29.  
  30.   for (cnt = 0; cnt < NUMGADS; cnt++) {
  31.     pzgad[cnt] = samplegad;  /* Structure copy */
  32.     pzgad[cnt].LeftEdge   = GADX + cnt * (GADWIDTH + 10);
  33.     if (cnt == NUMGADS) {
  34.       pzgad[cnt].GadgetID   = DIFF_EASY + cnt;
  35.       pzgad[cnt].NextGadget = &pzgad[cnt+1];
  36.     }
  37.   }
  38.   
  39.   AddGList (win, pzgad, -1, -1, NULL);
  40.   RefreshGList (win->FirstGadget, win, NULL, -1);
  41.  
  42.   cnt = -1;
  43.   while (true) {
  44.     while (msg = GetMsg(win->UserPort)) {
  45.       if (msg.Class == GADGETUP) 
  46.         cnt = ((struct Gadget *)(msg->IAddress)).GadgetID;
  47.       ReplyMsg (msg);
  48.       if (cnt != -1) {
  49.          RemoveGList (win, pzgads, -1);
  50.          return (cnt); 
  51.       }
  52.     }
  53.     Wait (1L << win->UserPort->mp_SigBit);
  54.   }
  55. }
  56.  
  57.  
  58.     
  59.